#pragma once
#include <QByteArray>
#include <QByteArrayList>

struct Invitation {
    quint16 id;
    quint16 roomId;
    quint16 hostId;

    Invitation() : Invitation(0, 0, 0) {}
    Invitation(const quint16& id, const quint16& roomId, const quint16& hostId) : id(id), roomId(roomId), hostId(hostId) {}

    const QByteArray toByteArray() const {
        return QByteArray::number(id) + "," + QByteArray::number(roomId) + "," + QByteArray::number(hostId);
    }

    static Invitation read(const QByteArray& data) {
        QByteArrayList list = data.split(',');
        Invitation invitation;
        if (list.size() == 2) {
            invitation.id = list[0].toUShort();
            invitation.roomId = list[1].toUShort();
            invitation.hostId = list[2].toUShort();
        }
        return invitation;
    }
};
